<template>
	<view>
		<!-- logo背景图 -->
		<logoBack :back="true"></logoBack>

		<!-- from表单 -->
		<view class="form">
			<view class="formCenter">
				<view class="inputView">
					<view class="input">
						<input placeholder-class="inputPla" type="text" placeholder="请输入账号" />
					</view>
				</view>
				<view class="inputView">
					<view class="input">
						<input class="code" type="text" placeholder-class="inputPla" placeholder="验证码" />
					</view>
					<view class="getCode" @click="startCountdown">{{ countdown === 0? '获取验证码' : countdown +'s' }}</view>
				</view>
				<view class="inputView">
					<view class="input">
						<input :type="passwordVisible1? 'text' : 'password'" placeholder-class="inputPla"
							placeholder="密码" />
					</view>
					<view class="hideBtn" @click="togglePasswordVisibility1">
						<image v-if="!passwordVisible1" class="hide" src="https://yun.qiongtuyule.comhttps://yun.qiongtuyule.com/static/img/notice/password.png" mode="">
						</image>
						<image v-if="passwordVisible1" class="show" src="https://yun.qiongtuyule.comhttps://yun.qiongtuyule.com/static/img/notice/account.png" mode="">
						</image>
					</view>
				</view>
				<view class="inputView">
					<view class="input">
						<input :type="passwordVisible2? 'text' : 'password'" placeholder-class="inputPla"
							placeholder="请确认密码" />
					</view>
					<view class="hideBtn" @click="togglePasswordVisibility2">
						<image v-if="!passwordVisible2" class="hide" src="https://yun.qiongtuyule.comhttps://yun.qiongtuyule.com/static/img/notice/password.png" mode="">
						</image>
						<image v-if="passwordVisible2" class="show" src="https://yun.qiongtuyule.comhttps://yun.qiongtuyule.com/static/img/notice/account.png" mode="">
						</image>
					</view>
				</view>
				<view class="inputView registerButton" @click="register">
					<text>立即注册</text>
				</view>
			</view>
		</view>

		<!-- agree -->
		<agree @agreeChange="handleAgreeChange"></agree>
	</view>
</template>

<script>
	import logoBack from "./components/logoBack.vue"
	import agree from "./components/agree.vue"
	export default {
		data() {
			return {
				countdown: 0,
				timer: null,
				passwordVisible1: false,
				passwordVisible2: false,
				agree: false
			};
		},
		components: {
			logoBack,
			agree
		},
		onShow() {

		},
		onLoad() {

		},
		methods: {
			// 获取验证码前端倒计时
			startCountdown() {
				if (this.countdown === 0) {
					this.countdown = 60;
					this.timer = setInterval(() => {
						this.countdown--;
						if (this.countdown === 0) {
							clearInterval(this.timer);
						}
					}, 1000);
				}
			},
			togglePasswordVisibility1() {
				this.passwordVisible1 = !this.passwordVisible1;
			},
			togglePasswordVisibility2() {
				this.passwordVisible2 = !this.passwordVisible2;
			},
			// 获取agree的判断值
			handleAgreeChange(value) {
				this.agree = value;
			},
			// 注册事件
			register() {

			}
		}
	};
</script>

<style lang="less" scoped>
	.form {
		margin-top: calc(43.5rpx * 2);
		display: flex;
		justify-content: center;

		.inputView {
			width: 600rpx;
			height: 100rpx;
			background-color: #F6F9FE;
			border-radius: 50rpx;
			margin-bottom: 20rpx;
			display: flex;
			position: relative;

			.input {
				width: 80%;
				padding-left: 58rpx;
				display: flex;
				align-items: center;
				font-size: 32rpx;

				.inputPla {
					color: #AAAFB5;
					font-weight: 500;
				}

				/deep/ .inputPla {
					color: #AAAFB5;
					font-weight: 500;
				}

				input {
					width: 85%;
				}

				.code {
					width: 55%;
				}
			}

			.getCode {
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				right: 16rpx;
				font-size: 28rpx;
				width: 198rpx;
				height: 72rpx;
				border: #419AFF 2rpx solid;
				border-radius: 36rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				color: #419AFF;
			}

			.hideBtn {
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				right: 46rpx;

				.hide {
					padding-top: 46rpx;
					padding-bottom: 38rpx;
					width: 45.1rpx;
					height: 23rpx;
				}

				.show {
					padding-top: 28rpx;
					padding-bottom: 27rpx;
					width: 45rpx;
					height: 45rpx;
				}
			}
		}

		.registerButton {
			background-color: #419AFF;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #fff;
			font-size: 32rpx;
			margin-top: 77rpx;
		}
	}
</style>